package com.example.demo.Dao;

import com.example.demo.domin.Form;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface FormDao extends JpaRepository<Form,Long>{

    @Query(value="  SELECT * FROM `fof`.`form` WHERE  `form_id`= form_id  ",nativeQuery = true)
    public  List<Form> getForms();

    @Query(value="  SELECT * FROM `fof`.`form` WHERE  `state`= true  ",nativeQuery = true)
    public  List<Form> getCollectedForm();

    @Modifying
    @Transactional
    @Query(value = "  DELETE FROM `fof`.`form` WHERE  `form_id`= form_id ", nativeQuery = true)
    public int deleteForm(@Param("id")Long id);



}
